package edu.wpi.cs509.ui.simulators;

import edu.wpi.cs509.ui.intfc.RulesInterface;

public class Rules implements RulesInterface {

	private static final String page[] = {
		
		// PAGE 1
		"Stratego is a board game featuring a 10 × 10 square board and two players with 40 pieces each. The objective of the game is to either find and capture the opponent's Flag, or capture so many of the opponent's pieces that he/she cannot make any further moves.\n"+
		"\n"+
		"Setup\n"+
		"Players may arrange their 40 pieces in any configuration on a designated 4 ×10 section of the playing board.\n"+ 
		"\n"+
		"Gameplay\n"+
		"Each player moves one piece per turn.\n"+ 
		"All movable pieces, with the exception of the Scout, may move only one step in a straight line vertically or horizontally.\n"+ 
		"Scouts can move any distance in a straight line.\n"+
		"If a piece is moved onto a square occupied by an opposing piece, their identities are revealed, the weaker piece is removed from the board, and the stronger piece is moved into the place formerly occupied by the weaker piece.\n"+ 
		"If the engaging pieces are of equal rank, they are both removed.\n"+ 
		"Two zones in the middle of the board cannot be entered by either player's pieces.\n"+
		"\n"+
		"Pieces\n"+
		"For most pieces, rank alone determines the outcome of an attack, but there are special pieces:\n"+
		"\n"+
		"The Flag cannot move. If you take you opponents flag you have won the game.\n"+ 
		"\n"+
		"Bombs cannot move. They eliminate all pieces that attack it, except for Miners  who are able to defuse bombs.\n"+ 
		"\n"+
		"The Spy is the lowest in rank but can eliminate the Marshallwhich is the highest-ranked piece.\n"+
		"\n"+
		"The Spy loses if it is attacked by the Marshall.\n"+ 
		"\n"+
		"Scouts can move any distance in a straight line.\n", 
		
		// PAGE 2
		"From highest rank to lowest the pieces are:\n"+
		"\n"+
		"Piece	Number available	Special Abilities\n"+
		"Bomb	6	Destroys any piece except Miner, cannot move\n"+
		"Marshall	1\n"+	 
		"General	1\n"+	 
		"Colonel	2\n"+ 
		"Major	3\n"+ 
		"Captain	4\n"+ 
		"Lieutenant	4\n"+ 
		"Sergeant	4\n"+
		"Miner	5	Can defuse bombs\n"+
		"Scout	8	Can move any distance in a straight line\n"+
		"Spy	1	Can defeat the Marshall (but will be defeated when attacked by the Marshall!)\n"+
		"Flag	1	Wins/loses the game when captured, cannot move\n"+
		"\n"+
		"This is all you need to know to play Stratego!\n"+
		"\n"+
		"There is no reason to make things more complicated for now, enjoy your games on OnlineStratego.com!\n"+ 
		"\n"+
		"Below are some Strategy tips from Wikipedia which I can advice you to read.\n",
		
		// PAGE 3	
		"Strategy\n"+
		"In contrast to chess, Stratego is a game with incomplete information. Collecting the information, planning, and strategic thinking play an important role in Stratego.\n"+
		"\n"+
		"Basic strategies\n"+
		"Overall strategy in Stratego involves:\n"+
		"placing one's pieces initially so as to protect the Flag, while possibly misleading the opponent as to where it is\n"+
		"making strong pieces available for attack\n"+
		"identifying patterns in the enemy's movement during game play that give clues as to the distribution of his or her forces\n"+
		"starting with stronger pieces and/or Bombs farther away from the Flag (although this is risky), so as to trick one's opponent into attacking the wrong side of the board\n"+
		"Placing the Spy too far forward, for example, makes it more likely to be captured early on, but placing it too far back may make it inaccessible when the enemy marshall is identified. Likewise, Miners are weak, but their ability to defuse Bombs may be needed early (although some players prefer to leave Bombs 'unexploded' as long as possible, particularly if they hamper an opponent's movements). The placement of 'reserve troops' in the rearmost row and deployment of Scouts, which can move in an unimpeded straight line, is also a strategic point.\n"+
		"During game play, players must identify Bombs without sacrificing too many troops, determine the probable location of the enemy Flag, and form an attack plan that takes into account the likely ranks of the troops and exact location of the Bombs that usually surround the Flag.\n"+
		"\n"+	
		"Flag placement\n"+
		"Since one of the win criteria is to capture the Flag, its placement is vital. It is commonly placed on the back row surrounded by two or three Bombs for protection. Some players will use this generalisation to their advantage and place the Flag somewhere unprotected, for example the Shoreline Bluff (also called 'the Lakeside Bluff'), i.e. placing the Flag directly adjacent to one of the lakes where the opponent may not think to look for it\n"+
		"\n",
	
		// PAGE 4
		"Bluffing\n"+
		"Some common bluffs include:\n"+
		"A cluster of Bombs set by itself may deceive one's opponent into thinking that the Flag is there when, in fact, it is on the other side of the board.\n"+
		"Charging with a small unit, e.g. a miner, towards a known medium sized unit, e.g. a major, with the view to get past and attack a bomb.\n"+
		"If the opponent's marshall wins its first battle (and is thus revealed), and a player immediately moves a piece near the back row on the other side, the opponent will probably assume that this piece is the Spy when, in fact, the Spy may be on the other side of the board (and already close to the Marshal). This is a common tactic as it may cause the Marshall to move next to the Spy, thereby allowing the spy to attack first.\n"+
		"One could threaten a known Colonel with an unrevealed Sergeant to convince the opponent to retreat.\n"+
		"Effective scouting\n"+
		"Scouts are very useful towards the end of the game, once the board is more clear. They can be used to identify bombs on the back row, reveal bluffs or even capture the flag. They are most effective when they are moved one space at a time until necessary, as the moment they move multiple spaces, they are identified as a scout. Since they can move along a whole line, they are also effective for catching a spy daring to take a step into one's territory, even when they are standing on the other side of the board.\n"+
		"\n"+
		"Spy strategies\n"+
		"In most games, it is advisable to have the Spy shadow a General or a Colonel. These pieces are normally vulnerable to attack by the opposing Marshal. Keeping a General or Colonel in the same vicinity as the spy allows an effective retreat to where the opponent's Marshall can be ambushed by the Spy.\n"+
		"Spy bluffs are also effective. For example, using a Sergeant to shadow a Colonel might confuse the opponent, and he may be reluctant to have his Marshall attack the Colonel.\n"+
		"\n"+
		"Miner strategies\n"+
		"Sophisticated players might identify opposing Bombs, but leave them in place, interfering with the enemy's movement. To do this, it is vital to memorize the location of all the opponent's Bombs as they are identified. By keeping the Miners unmoved in his own territory during the early game, a player can create the Bomb bluff, in which the opposing player may mistake those unmoved Miners for Bombs.\n"+
		"\n"+
		"Protecting pieces\n"+
		"One of the most important concepts of Stratego is the incomplete knowledge and misdirection, so the manual recommends taking a piece with one that is not much stronger than it, for example take a Captain with a Major. In the same manner, one strategy is to protect with an 'evens and odds' system, where a piece is protected by one which is two levels stronger than it, an odd piece protecting another odd piece, for example protecting the Captain with a Colonel.\n"+
		"\n"+
		"Enforcing an advantage\n"+
		"If a player is lucky enough to have gained an advantage over his opponent, it is worth enforcing that advantage, by trading equal pieces of higher strength. For example, attacking a Major with another Major is much more of a loss for the opponent if he doesn't have any Colonels, Generals or Marshalls remaining on the board.\n"+
		"\n"+
		"Attacking unknown pieces\n"+
		"A risky strategy, which might be necessary when losing, is to attack unknown, unmoved pieces with a strong piece. This strategy relies on odds, for example if a player attacks an unknown, unmoved piece with a General, it would lose to any of the 6 Bombs, the Marshall or the other General. Mathematically, the odds are 7 in 40, but realistically these can be improved by not attacking pieces which are likely to be Bombs, or by keeping track of the pieces already identified.\n"
	};
		
	private static final int pageCount = page.length;

	
	@Override
	public String getPage(int pagenum) throws IllegalArgumentException {
		if (pagenum >= pageCount) {
			throw new IllegalArgumentException("Invalid page count, valid range 1.." + pageCount);
		}
		return page[pagenum-1];
	}

	@Override
	public int getTotalPageCount() {
		return pageCount;
	}

}
